#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os, sys, re

def main():
    txtfile = open(sys.argv[1] + ".out1",'r')
    txt = txtfile.read()
    txtfile.close()
    stopwords = []
    with open("stop.txt",'r') as stopfile:
        for line in stopfile:
            word = line.split('|')[0]
            word = word.strip()
            if len(word) > 0:
                stopwords.append(word.decode('unicode-escape'))

    outfile = open(sys.argv[1] + ".out2", 'w')
    
    firstword = True

    for w in txt.split(' '):
        if not w.decode('unicode-escape') in stopwords:
            outfile.write(("" if firstword else " ") + w)
            firstword = False

    outfile.close()

if __name__ == "__main__":
    main()

